//
//  main.m
//  精通Objective-C
//
//  Created by 花强 on 2017/9/20.
//  Copyright © 2017年 花强. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "C9Greeter.h"

int main(int argc, char * argv[]) {
    @autoreleasepool {
        
        NSString * bundleGreeterPath;
        if (argc != 2) {
            NSLog(@"没有获得包路径！");
        }else{
            bundleGreeterPath = [NSString stringWithUTF8String:argv[1]];
            if (bundleGreeterPath == nil) {
                NSLog(@"Bundle not found at this path!");
            }else{

                NSString * filePath = [[NSBundle mainBundle]pathForResource:@"PathList" ofType:@"plist"];
                NSDictionary * dic = [NSDictionary dictionaryWithContentsOfFile:filePath];
                NSMutableDictionary * pathData;
                if (!dic) {
                    pathData = [NSMutableDictionary dictionary];
                }else{
                    pathData = [NSMutableDictionary dictionaryWithDictionary:dic];
                }
                [pathData setValue:bundleGreeterPath forKey:@"bundleGreeterPath"];
                BOOL success = [pathData writeToFile:filePath atomically:YES];
                NSLog(@"%d",success);
            }
        }
        
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
